﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using VitCode.ObjectResolutionHelper;

namespace VitCode.Castle.Entities
{
    [OrMemo("用户")]
    [Serializable]
    public class User : BaseEntity
    {

        public User(){}
        protected string m_Code;
        /// <summary>
        /// 用户编码
        /// </summary>
        [OrMemo("编码")]
        public virtual string Code
        {
            get { return m_Code; }
            set { m_Code = value; }
        }

        protected string m_Password;
        /// <summary>
        /// 密码
        /// </summary>
        [OrMemo("密码")]
        public virtual string Password
        {
            get { return m_Password; }
            set { m_Password = value; }
        }

        protected string m_Name;
        /// <summary>
        /// 姓名
        /// </summary>
        [OrMemo("姓名")]
        public virtual string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }

        protected string m_Number;
        /// <summary>
        /// 员工编号
        /// </summary>
        [OrMemo("工号")]
        public virtual string Number
        {
            get { return m_Number; }
            set { m_Number = value; }
        }

        protected string m_Email;
        /// <summary>
        /// Email
        /// </summary>
        [OrMemo("Email")]
        public virtual string Email
        {
            get { return m_Email; }
            set { m_Email = value; }
        }

        protected string m_Mobile;
        /// <summary>
        /// 手机号码
        /// </summary>
        [OrMemo("手机号码")]
        public virtual string Mobile
        {
            get { return m_Mobile; }
            set { m_Mobile = value; }
        }

        protected UserGroup m_UserGroup;
        /// <summary>
        /// 所属的用户组
        /// </summary>
        [OrMemo("所属用户组")]
        public virtual UserGroup UserGroup
        {
            get { return m_UserGroup; }
            set{ m_UserGroup = value;}
        }

        [OrMemo("所属商户")]
        public virtual ContactInfo Contact { get; set; }

        protected bool m_IsInUsed;
        /// <summary>
        /// 是否在用的标记
        /// </summary>
        [OrMemo("是否在用")]
        public virtual bool IsInUsed
        {
            get { return m_IsInUsed; }
            set { m_IsInUsed = value; }
        }

        protected bool m_HasRole = false;
        /// <summary>
        /// 只用于自动登录时判段是否拥有权限
        /// </summary>
        public virtual bool HasRole
        {
            get { return m_HasRole; }
            set { m_HasRole = value; }
        }

        /// <summary>
        /// 重写Equals方法
        /// </summary>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, this))
                return true;
            if (obj == null)
                return false;
            var sObj = obj as User;
            return sObj != null && (sObj.Id == Id || (sObj.Code == m_Code));
        }

        /// <summary>
        /// 重写GetHashCode方法
        /// </summary>
        public override int GetHashCode()
        {
            int hash = 44;
            hash = 27 * hash * Id.GetHashCode();
            return hash;
        }


        public override string ToString()
        {
            return m_Name;
        }


        public virtual ArrayList GetRelateObjectInfo()
        {
            var al = new ArrayList();
            return al;
        }

    }
}
